<script setup lang="ts">
import OrderRequest from '@/request/orderRequest';
import useToast from '@/hooks/useToast';

const props = defineProps<{ data: IOrderDetailInfo }>();
const { showToast } = useToast();
const infoState = ref<number>(props.data.infoState || 0);

// 确认修改
const handleConfirmModify = () => {
  OrderRequest.BusinessInfoEdit({ id: props.data.orderId, state: 1, hasLoading: true }).then(() => {
    showToast('操作成功', 'success');
    infoState.value = 0;
  });
};
</script>

<template>
  <view class="mb-12px" v-if="infoState === 5 || infoState === 9">
    <van-cell-group inset>
      <van-cell :title="infoState === 5 ? '商户已修改信息待确认' : infoState === 9 ? '商户拒绝取消订单' : ''" use-label-slot>
        <view slot="right-icon">
          <van-button size="small" type="primary" @click="handleConfirmModify"> 确认 </van-button>
        </view>
      </van-cell>
    </van-cell-group>
  </view>
</template>
